<?php

namespace app\model;

use think\Db;

class AdminPassport extends PassportCommon
{
    private static $obj = null;

    private $db_name = 'admin_passport';

    public function _initialize()
    {
        parent::_initialize();
        $this->db_name = 'admin_passport';
    }

    /**
     * 类入口
     * @return AdminPassport|null
     */
    public static function getInstance()
    {
        if (is_null(self::$obj))
            self::$obj = new self();
        return self::$obj;
    }

    /**
     * @param $arr_where
     * @param string $str_field
     * @param null $int_first_row
     * @param null $int_list_rows
     * @param null $str_order
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function toSelectLimit($arr_where, $str_field = '*', $int_first_row = null, $int_list_rows = null, $str_order = null)
    {
        return (array)Db::name($this->db_name)->where($arr_where)->field($str_field)->limit($int_first_row, $int_list_rows)->order($str_order)->limit(0, 1)->select();
    }
}